#pragma once

////////////////////////////////////////////////////////////////////////// delete
#define ccc_delete(_p_) if(_p_ != nullptr){ delete _p_; _p_ = nullptr; }
#define ccc_delete_array(_p_) if(_p_ != nullptr){ delete[] _p_; _p_ = nullptr; }
#define ccc_delete_array1(_p_, _n_)\
if(_p_ != nullptr)\
{\
	for(int _i_ = (_n_) - 1; _i_ >= 0; --_i_)\
	{\
		ccc_delete(_p_[_i_])\
	}\
	delete[] _p_;\
	_p_ = nullptr;\
}
#define ccc_delete_array2(_p_, _n_)\
if(_p_ != nullptr)\
{\
	for(int _i_ = (_n_) - 1; _i_ >= 0; --_i_)\
	{\
		ccc_delete_array(_p_[_i_])\
	}\
	delete[] _p_;\
	_p_ = nullptr;\
}



////////////////////////////////////////////////////////////////////////// STL
#define forr(_vect_,_i_) for(int _i_ = (int)_vect_.size() - 1; _i_ >= 0; --_i_)
#define forv(_vect_,_i_) for(int _size_ = (int)_vect_.size(), _i_ = 0; _i_ < _size_; ++_i_)
#define forit(_vect_,_it_) for(auto &_it_ = _vect_.begin(), _itend_ =  _vect_.end(); _it_ != _itend_; ++_it_)
#define forcit(_vect_,_it_) for(auto &_it_ = _vect_.cbegin(), _itend_ =  _vect_.cend(); _it_ != _itend_; ++_it_)
#define forrit(_vect_,_it_) for(auto &_it_ = _vect_.rbegin(), _itend_ =  _vect_.rend(); _it_ != _itend_; ++_it_)
#define fore(_enum_, _enum2_, _k_) for (int _k_ = (int)_enum_, _k2_ = (int)_enum2_ ; _k_ <= _k2_; ++_k_)

#define ccc_find_cit(_STL_, _V_) std::find(_STL_.cbegin(), _STL_.cend(), _V_)
#define ccc_find(_STL_, _V_) (ccc_find_it(_STL_, _V_) != _STL_.cend())